﻿using System.Web.UI.WebControls.WebParts;

namespace Trentacular.SharePoint.SmartEditorPart.Web.UI.WebParts
{
    public interface IWebPartEditor<T> where T : WebPart
    {
        /// <summary>
        /// Gets a reference to the
        /// <see cref="T:System.Web.UI.WebControls.WebParts.WebPart"/> control that is
        /// currently being edited.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// A <see cref="T:System.Web.UI.WebControls.WebParts.WebPart"/> that is
        /// currently in edit mode.
        /// </returns>
        T WebPartToEdit { get; set; }

        /// <summary>
        /// Saves the values in an
        /// <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart"/> control to the
        /// corresponding properties in the associated
        /// <see cref="T:System.Web.UI.WebControls.WebParts.WebPart"/> control.
        /// </summary>
        /// <returns>
        /// true if the action of saving values from the
        /// <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart"/> control to the
        /// <see cref="T:System.Web.UI.WebControls.WebParts.WebPart"/> control is
        /// successful; otherwise (if an error occurs), false.
        /// </returns>
        bool ApplyChanges();

        /// <summary>
        /// Retrieves the property values from a
        /// <see cref="T:System.Web.UI.WebControls.WebParts.WebPart"/> control for its
        /// associated <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart"/>
        /// control.
        /// </summary>
        void SyncChanges();
    }
}
